package org.intellij.doctree.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.util.ui.Tree;
import org.intellij.doctree.DocTree;
import org.intellij.doctree.DocTreeTransferHandler;
import org.intellij.doctree.node.DocTreeNode;

public class CutNode extends TreeEditAction {

    public void actionPerformed(AnActionEvent e) {
        Tree tree = getTree(e);
        DocTreeTransferHandler th = (DocTreeTransferHandler) tree.getTransferHandler();
        th.exportToClipboard(tree, th.getClipboard(tree), DocTreeTransferHandler.MOVE);
    }

    public void update(AnActionEvent e) {
        boolean actionEnabled = false;
        DocTree tree = getTree(e);
        if (tree != null) {
            DocTreeNode node = tree.getCurrentNode();
            if (node != null && node.isEditable()) actionEnabled = true;
        }
        e.getPresentation().setEnabled(actionEnabled);
    }

}
